Three dimensional graphics processing applications require the storage and processing of large amounts of data. In particular, color information and other information, e.g., stencil and depth data, that is typically stored in the framebuffer takes up a large amount of memory. In addition, the time it takes to transfer color data from memory to a graphics processor can negatively affect the ability to process graphics data. There is a need to reduce the amount of memory needed to store graphics data and to improve the ability to quickly transfer graphics data between memory and the processor. This problem can be understood by reviewing the way that graphics systems process data.
Computer systems are often used to generate and display graphics on a display. Display images are made up of thousands of tiny dots, where each dot is one of thousands or millions of colors. These dots are known as picture elements, or “pixels”. Each pixel has a color, with the color of each pixel being represented by a number value stored in the computer system.
A three dimensional display image, although displayed using a two dimensional array of pixels, may in fact be created by rendering a plurality of graphical objects. Examples of graphical objects include points, lines, polygons, and three dimensional solid objects. Points, lines, and polygons represent rendering “primitives” which are the basis for most rendering instructions. More complex structures, such as three dimensional objects, are formed from a combination or mesh of such primitives. To display a particular scene, the visible primitives associated with the scene are drawn individually by determining those pixels that fall within the edges of the primitive, and obtaining the attributes of the primitive that correspond to each of those pixels. The obtained attributes are used to determine the displayed color values of applicable pixels.
Sometimes, a three dimensional display image is formed from overlapping primitives or surfaces. A blending function based on an opacity value associated with each pixel of each primitive is used to blend the colors of overlapping surfaces or layers when the top surface is not completely opaque. The final displayed color of an individual pixel may thus be a blend of colors from multiple surfaces or layers.
Aliasing
A phenomenon termed, “aliasing” frequently occurs at the border between two overlapping primitives or surfaces. In aliasing, straight lines are displayed such that a stair step effect develops. Pixels are not mathematical points which are either on or off a line. Instead, pixels have a finite width, and, typically, a pixel is considered on a line if the line passes through the pixel's area.
FIG. 1 illustrates an example of aliasing. Edge 1 of a polygon (800) passes through pixels 5, (825), 6 (830), 7 (835), 8 (840), and 9 (845). Thus, polygon 800 covers pixels 5, 6, 7, 8, and 9. These pixels are shaded and pixels 1 (805), 2 (810), 3 (815), and 4 (820) are not shaded. The resulting display looks like a jagged stair step rather than a line.
Anti-Aliasing
Techniques for removing or reducing artifacts by smoothing the appearance of the displayed image and/or increasing the spatial frequency characteristics of the display are known as “anti-aliasing” techniques. One anti-aliasing technique adjusts pixel colors where aliasing occurs in an attempt to smooth the display. For example, a pixel's intensity may depend on the length of the line segment that falls in the pixel's area.
FIG. 2A illustrates an example of anti-aliasing. Edge 1 (900) of a polygon passes through pixels 5, (925), 6 (930), 7 (935), 8 (940), and 9 (945). However, the edge passes through a small portion of pixel 5, so the intensity of the pixel is low. The intensity of pixel 8 is higher because more of the edge passes through pixel 8. Pixel 9 is completely within the polygon, thus it has the darkest shade. Likewise, the intensities of pixels 6 and 7 are also higher. Pixels 1 (905), 2 (910), 3 (915), and 4 (920) are not shaded because the edge does not pass through them. These pixels lie outside of polygon 900. With the intensity adjusted per the amount of pixel lying within the polygon, the resulting edge on the display is smoother than the aliased edge.
Super-sampling is an anti-aliasing technique that increases the spatial quantization of the display's array by increasing the number of data samples that are taken at or around each pixel location corresponding to a portion of the image to be displayed, and then combining the resulting values of these multiple data samples to obtain a final display value for each pixel location. In prior art systems, each super-sample typically includes both a color-value (for either color or gray-scale systems) and a Z-value (a representation of the depth of a pixel which is used to perform hidden surface removal) relating to a reference point (one reference point per super-sample) within that pixel.
Another well-known anti-aliasing technique for determining the color of a pixel is multi-sampling. Unlike super-sampling, multi-sampling uses the color values from the original sample for all sub-samples, and relies on the sub-samples positions to achieve its effect. The number of samples per pixel may vary from application to application. Each pixel is divided into sub-pixels, or samples. A color is determined for each sample, and the sample colors are combined to yield one color for the entire pixel. For example, suppose that each pixel in FIG. 2A is further divided into four samples. Then each sample would cover ¼ of the area of the original pixel, as shown in FIG. 2B. Thus pixel 6 (930) would be of a darker color because two of its samples are covered by the intersecting edge. In contrast, pixel 5 (925) would be of a light color because only one of its samples is covered by the intersecting edge. Thus in simplified terms, pixel 6 (930) may have 50% color contribution from the dark color from polygon 900 and 50% color contribution from the clear background. Thus its final color would be of a 50% shading. Pixel 5 (925) may have 25% color contribution from the dark color from polygon 900 and 75% color contribution from the clear background. Thus its final color would be of a 25% shading.
It must be noted that this is an illustration only and in practice, the number of samples do vary and the granularity depicted in the figures are not to proportion to the actual thickness of the lines and pixels. Also, it can be seen that the more samples a system employs, the better the anti-aliasing can become. However, the demand on system resources increases in proportion to the number of samples.
Rendering
In some cases, graphical data is rendered by executing instructions from an application that is drawing data to a display. During image rendering, three dimensional data is processed into a two dimensional image suitable for display. The three dimensional image data represents attributes such as color, opacity, texture, depth, and perspective information. The draw commands from a program drawing to the display may include, for example, X and Y coordinates for the vertices of the primitive, as well as some attribute parameters for the primitive, and a drawing command. Examples of attribute parameters for primitives include color and depth, or Z data. Three-dimensional data includes not only horizontal and vertical components on an X and Y axis, but also include a depth component along an axis labeled Z. The execution of drawing commands to generate a display image is known as graphics processing.
Three-dimensional data processing is very data intensive. The color data for a pixel is typically 24 or 32 bits. For a megapixel display, large amounts of storage are required just to store the data to be displayed. Compression schemes are needed to reduce the amount of data transferred between the memory and the processor to improve performance. Conventional graphics processors and their associated graphics processing units (GPUs) use these compression schemes to reduce the bandwidth needed to access the color data or other types of data stored in the frame buffer memory.
These compression schemes usually operate on tiles that include color data or other types of data typically stored in a framebuffer, e.g., depth data, stencil data, etc., for several pixels. Reduction compression can reduce several pixels in a tile or several sub-pixel samples in a pixel down to one color value for a pixel and is possible when the samples all share similar values in their red, green, blue, alpha, etc. components (or channels). Conventional systems that employ multi-sampling anti-aliasing techniques are generally suited to use reduction compression because the “reduction ratio” (number of samples in a group to be reduced to one color value) used by such systems can be identical to the number of samples in a pixel. For example, in the example illustrated in FIG. 2B, the reduction ratio that would be used in conventional systems would be 4:1, which is commensurate with the 4 sub-pixel samples used per pixel. However, because they tie the number of samples in a group being reduced to the reduction ratio, conventional systems may be limited in the advantages they offer.
Also, conventional compression schemes are designed to minimize visual artifacts in an image. When the color data for multiple sub-pixel samples within a pixel or multiple pixels within a tile are compressed, visual artifacts may be introduced. For example, assume a tile includes a blue background and a red primitive that partially covers the tile. The color data for the tile is compressed by combining the color data to produce a purple color for the pixels along the edge where the red primitive overlaps the blue background and the compressed color data is written to memory. Visual artifacts are introduced when a second red primitive is received that covers the remaining portion of the tile. The compressed color data is read from memory and combined with the second red primitive to produce compressed color data that is reddish-purple along the edge. The final compressed color along the edge should be red, but instead the final compressed color along the edge is reddish-purple. None of the purple background color should be included in the final compressed color. The visual artifacts may appear as cracks at primitive edges in meshes. Conventional systems were unable to compress color data or other types of data, e.g., depth and stencil data for a tile without introducing visual artifacts.